<template>
	<view class="page">
		<view class="duihuanHeader">
			<view class="wenzi">当前礼品卡</view>
			<view class="flex flex-center">
				<view class="prcie">{{dataInfo.balance2}}</view>
				<view class="wenzis" @click="goUrl('/pages/ConsumeRecord/ConsumeRecord')">明细</view>
				<tui-icon name="arrowright" color="#fff" :size="20"></tui-icon>
			</view>
		</view>
		<view class="goods-data">
			<view class="goods-list">
				<view :class="isList?'list-view':'list-li'" v-for="(item,index) in goodsList" :key="index" v-if="goodsList.length!=0" @click="onGoodsList(item.code)">
					<view class="thumb">
						<image :src="item.cover" mode="heightFix"></image>
					</view>
					<view class="item">
						<view class="title">
							<text class="one-omit">{{item.name}}</text>
						</view>
						<view class="price flex flex-align flex-bt">
							<view class="retail-price">
								<text class="max">{{item.price_selling}}礼品卡</text>
							</view>
							<view class="btns">立即兑换</view>
						</view>
					</view>
				</view>
				<view class="empty-box"  v-if="goodsList.length==0" style="padding-top: 100rpx;">
					<image src="../../static/ic_nodata.png" mode=""></image>
					<view class="">暂无数据</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	// 引入mescroll-mixins.js
	export default {
		data() {
			return {
				type:0,
				mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
				// 下拉刷新的配置(可选, 绝大部分情况无需配置)
				downOption: {},
				// 上拉加载的配置(可选, 绝大部分情况无需配置)
				upOption: {
				},
				// 列表视图切换
				isList: true,
				// 筛选弹窗
				isScreen: false,
				// 筛选切换
				screenShow: 0,
				// 抽屉
				isDrawer: false,
				keyword: '',
				goodsList:[
				 
				],
				page:1,
				order:'sort',
				sort:'asc',
				entrance_id:'',
				dataInfo:'',
			}
		},
		onLoad(params) {
			this.keyword = decodeURIComponent(params.keyword||'');
			this.entrance_id = params.id
		},
		onShow() {
			let that = this
			that.getData()
			that.page=1
			that.goodsList = []
			that.getList()
		},
		onReachBottom() {
			let that = this
			that.page++
			that.getList()
		},
		// #ifdef MP
		onShareAppMessage() {
			return {
				title:'分享海报',
				path:'/pages/home/home?inviter_code='+uni.getStorageSync('inviter_code'),
			};
		},
		// #endif
		methods: {
			searchs(){
				let that = this
				that.page=1
				that.goodsList =[]
				that.getList()
				
			},
			goUrl(e){
				this.tui.href(e)
			},
			getData(){
				let that = this
				that.tui.request("api.auth.center/get", "POST", {}, false, false, true).then((res) => {
					if (res.code == 1) {
						that.dataInfo = res.data
					}
				}).catch((res) => {})
			},
			getList(){
				let that = this
				that.tui.request("api.data/goodsExchange", "POST", {page:that.page}, false, false, true).then((res) => {
					if (res.code == 1) {
						that.goodsList = that.goodsList.concat(res.data.list)
					}
				}).catch((res) => {})
			},
			/**
			 * 返回点击
			 */
			onBack(){
				uni.navigateBack();
			},
			/**
			 * 综合点击
			 * @param {Number} type
			 */
			onSynthesize(type,d){
				let that = this
				if(d==1&&that.sort=='asc'){
					that.sort = 'desc'
				}else if(d==1&&that.sort=='desc'){
					that.sort = 'asc'
				}
				that.order = type;
				that.isScreen = !that.isScreen;
				that.page=1
				that.goodsList = []
				that.getList()
				console.log(that.sort)
			},
			/**
			 * 商品列表点击
			 */
			onGoodsList(e){
				uni.navigateTo({
					url: '/pages/GoodsDetails/GoodsDetails?id='+e,
					animationType: 'zoom-fade-out',
					animationDuration: 200
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import  'SearchGoodsList.scss';
	.duihuanHeader{background:url('../../static/lipinBj.jpg') no-repeat;padding: 120rpx 0;text-align: center;background-size: 100% 100%;
		.wenzi{color: #fff;font-size: 32rpx;}
		.flex{width: 250rpx;margin: 20rpx auto;font-weight: bold;align-items: center;color: #fff;
			.prcie{font-size:56rpx;margin-top: -10rpx;margin-right: 10rpx;}
			
		}
	}
</style>
